<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:security="http://www.springframework.org/security/tags" xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">活动编辑</ui:define>
    <ui:define name="content">
        <h:form>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                        <p:commandButton value="编辑" icon="fa fa-edit"
                                         actionListener="#{loanAdvertInfoBean.changeStatusToEdit}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{loanAdvertInfoBean.isView()}"/>
                        <p:commandButton value="保存" icon="fa fa-save"
                                         actionListener="#{loanAdvertInfoBean.onSave}"
                                         rendered="#{loanAdvertInfoBean.isNotView()}"
                                         update="@form"/>
                        <p:commandButton value="取消" icon="fa fa-reply"
                                         actionListener="#{loanAdvertInfoBean.changeStatusToView}"
                                         rendered="#{loanAdvertInfoBean.isEdit()}"
                                         process="@this"
                                         update="@form"/>
                        <p:commandButton icon="fa fa-reply-all" value="返回"
                                         action="#{loanAdvertInfoBean.onReturn(currentUserBean.back)}"
                                         process="@this"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>活动信息编辑</h1>
                            <p:panelGrid columns="4"
                                         columnClasses="ui-grid-col-2,ui-grid-col-4,ui-grid-col-2,ui-grid-col-4"
                                         layout="grid" styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;">

                                <p:outputLabel for="productId" value="产品"/>
                                <p:selectCheckboxMenu label="-请选择-" id="productId" value="#{loanAdvertInfoBean.$.prdId}" disabled="#{loanAdvertInfoBean.isView()}"
                                                      updateLabel="true" multiple="true" filter="true">
                                    <f:selectItem itemLabel="全产品" itemValue="0"/>
                                    <f:selectItems
                                            value="#{loanAdvertInfoBean.getCommProductIds()}"
                                            var="product"
                                            itemLabel="#{product.name}" itemValue="#{product.productId}"/>
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="excludePrdId" value="剔除产品"/>
                                <p:selectCheckboxMenu label="-请选择-" id="excludePrdId" value="#{loanAdvertInfoBean.$.excludePrdId}" disabled="#{loanAdvertInfoBean.isView()}"
                                                      updateLabel="true" multiple="true" filter="true">
                                    <f:selectItem itemLabel="全产品" itemValue="0"/>
                                    <f:selectItems
                                            value="#{loanAdvertInfoBean.getCommProductIds()}"
                                            var="product"
                                            itemLabel="#{product.name}" itemValue="#{product.productId}"/>
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="channelId" value="渠道"/>
                                <p:selectCheckboxMenu label="-请选择-" id="channelId" value="#{loanAdvertInfoBean.$.channel}"
                                                      disabled="#{loanAdvertInfoBean.isView()}"
                                                      updateLabel="true" multiple="true" filter="true">
                                    <f:selectItems value="#{loanAdvertInfoBean.commProductChannels}" var="channel"
                                                   itemValue="#{channel.channelCode}" itemLabel="#{channel.channelName}"/>
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="excludeChannel" value="剔除渠道"/>
                                <p:selectCheckboxMenu label="-请选择-" id="excludeChannel" value="#{loanAdvertInfoBean.$.excludeChannel}"
                                                      disabled="#{loanAdvertInfoBean.isView()}"
                                                      updateLabel="true" multiple="true" filter="true">
                                    <f:selectItems value="#{loanAdvertInfoBean.commProductChannels}" var="channel"
                                                   itemValue="#{channel.channelCode}" itemLabel="#{channel.channelName}"/>
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="platform" value="平台"/>
                                <p:selectOneMenu id="platform" value="#{loanAdvertInfoBean.$.platform}" disabled="#{loanAdvertInfoBean.isView()}">
                                    <f:selectItem itemLabel="通用" itemValue="0" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="安卓" itemValue="1"/>
                                    <f:selectItem itemLabel="ios" itemValue="2"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="advertSpace" value="广告位"/>
                                <p:selectCheckboxMenu id="advertSpace" label="-请选择-" value="#{loanAdvertInfoBean.$.advertSpaces}" disabled="#{loanAdvertInfoBean.isView()}"
                                                      updateLabel="true" multiple="true" filter="true" filterMatchMode="contains">
                                    <f:selectItems
                                            value="#{loanAdvertInfoBean.commSysCodes}"
                                            var="commsyscode"
                                            itemLabel="#{commsyscode.kindname}--#{commsyscode.code}" itemValue="#{commsyscode.code}"/>
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="redirectType" value="跳转类型"/>
                                <p:selectOneMenu id="redirectType" value="#{loanAdvertInfoBean.$.redirectType}" disabled="#{loanAdvertInfoBean.isView()}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="详情页" itemValue="1"/>
                                    <f:selectItem itemLabel="API资料页" itemValue="2"/>
                                    <f:selectItem itemLabel="结果页" itemValue="3"/>
                                    <f:selectItem itemLabel="合作方H5页" itemValue="4"/>
                                    <f:selectItem itemLabel="车主信用卡" itemValue="5"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="activityName" value="活动名称"/>
                                <p:selectCheckboxMenu id="activityName" label="-请选择-" value="#{loanAdvertInfoBean.$.activityIds}" disabled="#{loanAdvertInfoBean.isView()}"
                                                      updateLabel="true" multiple="true" filter="true" filterMatchMode="contains">
                                    <f:selectItems
                                            value="#{loanAdvertInfoBean.productInfos}"
                                            var="loanActivity"
                                            itemLabel="#{loanActivity.name}" itemValue="#{loanActivity.id}"/>
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="position" value="位置"/>
                                <p:inputNumber id="position" value="#{loanAdvertInfoBean.$.position}"
                                               disabled="#{loanAdvertInfoBean.isView()}"
                                               decimalPlaces="0"/>

                                <p:outputLabel for="tag" value="活动标签(Enter键分隔)"/>
                                <p:chips id="tag" value="#{loanAdvertInfoBean.$.tag}"
                                         disabled="#{loanAdvertInfoBean.isView()}"/>

                                <p:outputLabel for="startTime" value="指定上线时间"/>
                                <p:calendar id="startTime"
                                            value="#{loanAdvertInfoBean.$.startTime}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATETIME_FORMAT')}"
                                            disabled="#{loanAdvertInfoBean.isView()}"
                                            readonlyInput="true"/>

                                <p:outputLabel for="endTime" value="指定下线时间"/>
                                <p:calendar id="endTime"
                                            value="#{loanAdvertInfoBean.$.endTime}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATETIME_FORMAT')}"
                                            disabled="#{loanAdvertInfoBean.isView()}"
                                            readonlyInput="true"/>

                                <p:outputLabel for="fixedStartTime" value="每天上线时间"/>
                                <p:calendar id="fixedStartTime" value="#{loanAdvertInfoBean.$.fixedStartTime}" pattern="HH:mm"
                                            timeOnly="true" disabled="#{loanAdvertInfoBean.isView()}"/>

                                <p:outputLabel for="fixedEndTime" value="每天下线时间"/>
                                <p:calendar id="fixedEndTime" value="#{loanAdvertInfoBean.$.fixedEndTime}" pattern="HH:mm"
                                            timeOnly="true" disabled="#{loanAdvertInfoBean.isView()}"/>

                                <p:outputLabel for="upperLimit" value="每日控量上限"/>
                                <p:inputNumber id="upperLimit" value="#{loanAdvertInfoBean.$.upperLimit}"
                                               disabled="#{loanAdvertInfoBean.isView()}"
                                               decimalPlaces="0"/>
                            </p:panelGrid>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
